package com.twu.biblioteca.service;

import com.twu.biblioteca.exceptions.AssetUnavailableException;
import com.twu.biblioteca.exceptions.MovieDoesNotBelongToLibraryException;
import com.twu.biblioteca.model.Library;
import com.twu.biblioteca.model.LibraryService;
import com.twu.biblioteca.model.ServiceResult;

/**
 * Created by aave on 2/10/2014.
 */
public class ReturnMovieService extends LibraryService {

    private static String name = "Return movie";

    public ReturnMovieService(Library library) {
        super(library);
    }

    @Override
    public ServiceResult performService() {
        return null;
    }

    public ServiceResult performService(Integer id) {
        try {
            library.returnMovie(library.getMovie(id));
            return new ServiceResult("You have successfully borrowed the movie.");
        } catch (MovieDoesNotBelongToLibraryException e) {
            return new ServiceResult("Movie does not exist.");
        }
    }

    @Override
    public String getName() {
       return name;
    }
}
